package com.example.guideapp.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.example.guideapp.utils.DatabaseManage;
import com.example.guideapp.utils.MySqliteDatabaseHelper;
import com.example.guideapp.utils.Util;

public class FirstInActivity extends AppCompatActivity {

    private boolean isFirstIn;

    private Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SharedPreferences sp = Util.getMySharedPreferences(this);
        isFirstIn = sp.getBoolean("isFirstIn",true);

        if (isFirstIn){
            intent = new Intent(this,GuideActivity.class);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    MySqliteDatabaseHelper helper = DatabaseManage.getInstance(FirstInActivity.this);
                    SQLiteDatabase db = helper.getReadableDatabase();
                    db.close();

                }
            }).start();
        }else {
            intent = new Intent(this,WelcomeActivity.class);
        }
        startActivity(intent);
        finish();
    }
}
